//
//  MGClientSocket.h
//  iFlyQDMG
//
//  Created by ifly on 20/9/2018.
//  Copyright © 2018 Meiyang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <GCDAsyncSocket.h>

typedef void(^JCSocketReciveDataBlock)(NSString *data,NSString *type);

@interface MGClientSocket : NSObject

//sockct
@property(nonatomic,strong)GCDAsyncSocket* socket;

///链接服务器
- (BOOL)jcConnecteServerWithHost:(NSString *)host onPort:(uint16_t )port;
///断开服务器
- (void)jcDisconnect;
///发送数据
- (void)jcSendDataWithType:(int)type withDic:(NSMutableDictionary *)dic ;
///回调数据
- (void)jcReciveData:(JCSocketReciveDataBlock)reciveBlock;



///拆包的到lenght
+ (NSInteger)unpackingLenght:(NSString *) packing;

///拆包的到type
+ (NSString *)unpackingHeard:(NSString *)packing;

///拆包的到json
+ (NSDictionary *)unpackingDicWith:(NSString *) packing;

///拆包的到NSMutableArray
+ (NSMutableArray *) unpackingArrWith:(NSString *)packing WithHeard:(NSString *)str;

///单利
+(instancetype) share;

@end

